package com.report.controller;

import cn.dev33.satoken.annotation.SaIgnore;
import cn.hutool.core.util.IdUtil;
import com.report.component.ScanCodePayComponent;
import com.report.dto.request.ScanCodePayReq;
import com.report.dto.request.ScanPayReq;
import com.report.properties.PayProperties;
import com.zmh.framework.pay.model.PayOrderRequestDTO;
import com.zmh.framework.pay.service.impl.AlPay;
import com.zmh.framework.pay.service.impl.WxPay;
import com.zmh.framework.util.Result;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @author summer
 * @date 2024-06-28 15:29
 */

@RestController
@RequestMapping(value = "/scanCode")
@AllArgsConstructor
@SaIgnore
public class ScanCodePayController {

    private final ScanCodePayComponent scanCodePayComponent;

    private final PayProperties payProperties;




    /**
     * pc端支付
     * @param scanCodePayReq
     * @return
     */
    @PostMapping(value = "/pay")
    public Result<ScanPayReq> scanCodePay(@RequestBody ScanCodePayReq scanCodePayReq, HttpServletRequest request) {
        ScanPayReq scanPayReq = scanCodePayComponent.scanCodePay(scanCodePayReq, request);
        return Result.successResult(scanPayReq);
    }

    /**
     * 切换支付方式
     * @param scanPayReq
     * @param request
     * @return
     */
    @PostMapping(value = "/changePayMethod")
    public Result<ScanPayReq> changePayMethod(@RequestBody ScanPayReq scanPayReq, HttpServletRequest request) {
        ScanPayReq scan=scanCodePayComponent.changePayMethod(scanPayReq,request);
        return Result.successResult(scan);
    }

}
